<template>
	<view class="hospital">
		<u-search v-model="value" @search="search()" @custom="search"></u-search>
		<u-grid>
			<u-grid-item v-for="item in list" style="margin-top: 30px; margin-bottom: 20px;" @click="tonext(item.id)">
				<image :src="'http://124.93.196.45:10001'+item.imgUrl" style="width: 80px; height: 80px; border-radius: 50%;"></image>
				<view class="h1">
					<text>{{item.hospitalName}}</text>
					<text>星级：{{item.level}}</text>
				</view>
			</u-grid-item>
		</u-grid>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				allist:[],
				value:''
			}
		},
		onLoad() {
			this.getlist()
		},
		methods: {
			getlist(){
				this.api.get('/prod-api/api/hospital/hospital/list').then(res=>{
					this.list=res.data.rows
					this.allist=res.data.rows
				})
			},
			search(){
				if(this.value===''){
					this.list=this.allist
				}else{
					this.list=[]
					for(let i=0;i<this.allist.length;i++){
						if(this.allist[i].hospitalName.indexOf(this.value)>=0){
							this.list.push(this.allist[i])
						}
					}
				}
			},
			tonext(id){
				uni.navigateTo({
					url:'hospitalDetail/hospitalDetail?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
.h1{
	display: flex;
	flex-direction: column;
	text-align: center;
}
</style>
